#include "CTrackbar.h"

CTrackbar::CTrackbar() {
  m_hTrackbar = NULL;
}

void CTrackbar::SetHandle(HWND hTrack) {
  m_hTrackbar = hTrack;
}

HWND CTrackbar::GetHandle() {
  return m_hTrackbar;
}

HWND CTrackbar::Create(DWORD dwStyle, int x, int y, int nWidth, int nHeight,
    HWND hParentWnd, UINT nID) {
  m_hTrackbar = ::CreateWindow(TRACKBAR_CLASS, NULL, WS_CHILD | WS_VISIBLE | dwStyle, x, y, nWidth, nHeight, hParentWnd, (HMENU)(long long)nID, NULL, NULL);

  return m_hTrackbar;
}

BOOL CTrackbar::Destroy() {
  return ::DestroyWindow(m_hTrackbar);
}

INT CTrackbar::SetBuddy(BOOL bLocation, HWND hwndBuddy) {
  return ::SendMessage(m_hTrackbar, TBM_SETBUDDY, bLocation, (LPARAM)hwndBuddy);
}

INT CTrackbar::GetBuddy(BOOL bLocation) {
  return ::SendMessage(m_hTrackbar, TBM_GETBUDDY, bLocation, 0);
}

INT CTrackbar::GetChannelRect(LPRECT lpRect) {
  return ::SendMessage(m_hTrackbar, TBM_GETCHANNELRECT, 0, (LPARAM)lpRect);
}

INT CTrackbar::SetLineSize(int nLineSize) {
  return ::SendMessage(m_hTrackbar, TBM_SETLINESIZE, 0, nLineSize);
}

INT CTrackbar::GetLineSize() {
  return ::SendMessage(m_hTrackbar, TBM_GETLINESIZE, 0, 0);
}

INT CTrackbar::GetNumTicks() {
  return ::SendMessage(m_hTrackbar, TBM_GETNUMTICS, 0, 0);
}

INT CTrackbar::SetPageSize(int nPageSize) {
  return ::SendMessage(m_hTrackbar, TBM_SETPAGESIZE, 0, nPageSize);
}

INT CTrackbar::GetPageSize() {
  return ::SendMessage(m_hTrackbar, TBM_GETPAGESIZE, 0, 0);
}

INT CTrackbar::SetPos(BOOL bRedraw, int nPosition) {
  return ::SendMessage(m_hTrackbar, TBM_SETPOS, bRedraw, nPosition);
}

INT CTrackbar::GetPos() {
  return ::SendMessage(m_hTrackbar, TBM_GETPOS, 0, 0);
}

INT CTrackbar::SetRange(BOOL bRedraw, int nMinimum, int nMaximum) {
  return ::SendMessage(m_hTrackbar, TBM_SETRANGE, bRedraw,
      MAKELONG(nMinimum, nMaximum));
}

INT CTrackbar::SetRangeMin(BOOL bRedraw, int nMinimum) {
  return ::SendMessage(m_hTrackbar, TBM_SETRANGEMIN, bRedraw, nMinimum);
}

INT CTrackbar::GetRangeMin() {
  return ::SendMessage(m_hTrackbar, TBM_GETRANGEMIN, 0, 0);
}

INT CTrackbar::SetRangeMax(BOOL bRedraw, int nMaximum) {
  return ::SendMessage(m_hTrackbar, TBM_SETRANGEMAX, bRedraw, nMaximum);
}

INT CTrackbar::GetRangeMax() {
  return ::SendMessage(m_hTrackbar, TBM_GETRANGEMAX, 0, 0);
}

INT CTrackbar::SetSel(BOOL bRedraw, int nMinimum, int nMaximum) {
  return ::SendMessage(m_hTrackbar, TBM_SETSEL, bRedraw,
      MAKELONG(nMinimum, nMaximum));
}

INT CTrackbar::ClearSel(BOOL bRedraw) {
  return ::SendMessage(m_hTrackbar, TBM_CLEARSEL, bRedraw, 0);
}

INT CTrackbar::SetSelStart(BOOL bRedraw, int nStart) {
  return ::SendMessage(m_hTrackbar, TBM_SETSELSTART, bRedraw, nStart);
}

INT CTrackbar::GetSelStart() {
  return ::SendMessage(m_hTrackbar, TBM_GETSELSTART, 0, 0);
}

INT CTrackbar::SetSelEnd(BOOL bRedraw, int nEnd) {
  return ::SendMessage(m_hTrackbar, TBM_SETSELEND, bRedraw, nEnd);
}

INT CTrackbar::GetSelEnd() {
  return ::SendMessage(m_hTrackbar, TBM_GETSELEND, 0, 0);
}

INT CTrackbar::SetThumbLength(UINT nLength) {
  return ::SendMessage(m_hTrackbar, TBM_SETTHUMBLENGTH, nLength, 0);
}

INT CTrackbar::GetThumbLength() {
  return ::SendMessage(m_hTrackbar, TBM_GETTHUMBLENGTH, 0, 0);
}

INT CTrackbar::GetThumbRect(LPRECT lpRect) {
  return ::SendMessage(m_hTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)lpRect);
}

INT CTrackbar::SetTipSide(int nLocation) {
  return ::SendMessage(m_hTrackbar, TBM_SETTIPSIDE, nLocation, 0);
}

INT CTrackbar::SetTick(int nPosition) {
  return ::SendMessage(m_hTrackbar, TBM_SETTIC, 0, nPosition);
}

INT CTrackbar::GetTick(int nTick) {
  return ::SendMessage(m_hTrackbar, TBM_GETTIC, nTick, 0);
}

INT CTrackbar::GetPTicks() {
  return ::SendMessage(m_hTrackbar, TBM_GETPTICS, 0, 0);
}

INT CTrackbar::ClearTicks(BOOL bRedraw) {
  return ::SendMessage(m_hTrackbar, TBM_CLEARTICS, bRedraw, 0);
}

INT CTrackbar::SetTickFreq(int nFrequency) {
  return ::SendMessage(m_hTrackbar, TBM_SETTICFREQ, nFrequency, 0);
}

INT CTrackbar::GetTickPos(int nTic) {
  return ::SendMessage(m_hTrackbar, TBM_GETTICPOS, nTic, 0);
}

INT CTrackbar::SetToolTips(HWND hwndToolTips) {
  return ::SendMessage(m_hTrackbar, TBM_SETTOOLTIPS, (WPARAM)hwndToolTips, 0);
}

INT CTrackbar::GetToolTips() {
  return ::SendMessage(m_hTrackbar, TBM_GETTOOLTIPS, 0, 0);
}

INT CTrackbar::SetUnicodeFormat(BOOL bUnicode) {
  return ::SendMessage(m_hTrackbar, TBM_SETUNICODEFORMAT, bUnicode, 0);
}

INT CTrackbar::GetUnicodeFormat() {
  return ::SendMessage(m_hTrackbar, TBM_GETUNICODEFORMAT, 0, 0);
}

